<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Schedule</title>
        <link type="text/css" rel="stylesheet" href="resources/css/schedule.css" />
    </h:head>
    <h:body>
        <div id="header"></div>
        <a  href="homepage.xhtml?faces-redirect=true" ><img id="logo" src="resources/images/logo.png"/></a> 
        <h:form>
            <p:dock position="top" maxWidth="30" itemWidth="55">
                <p:menuitem  value="Invitations" action="#{invitationBean.retriveInvitation()}" icon="/resources/images/mail.png"/>
                <p:menuitem  action="#{eventBean.tocreateEvent()}" value="New Event" icon="/resources/images/new.png"/>
                <p:menuitem value="Notifications" action="#{userBean.notifications()}" icon="/resources/images/Notification.png"/>
            </p:dock>
            <p:panelGrid id="panelSearch" columns="2">
                <p:autoComplete placeholder="Search"  id="themePojo" value="#{scheduleUserBean.selectedTheme}" completeMethod="#{autoCompleteView.completeTheme}"
                                var="theme" itemLabel="#{theme.name}" itemValue="#{theme}" forceSelection="true" converter="themeConverter" minQueryLength="3"/>
                <p:commandButton icon="ui-icon-search" id="search" value="Search" action="#{scheduleUserBean.search()}"/>
                <h:commandLink style="font-size: 75%;" id="toolTipFade" value="Advanced search" action="advsearch?faces-redirect=true"/>
            </p:panelGrid>
            <p:menuButton value ="Options"> 
                <p:menuitem value="Profile" action="#{userBean.goToProfile()}" icon="ui-icon-person"/>
                <p:menuitem value="Export Events" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);" icon="ui-icon-arrowthick-1-s" actionListener="#{scheduleBean.createCalendarIcs()}">
                    <p:fileDownload value="#{scheduleBean.export()}" />
                </p:menuitem>
                <p:menuitem value="Import Events" onclick="PF('importDialog').show();" icon="ui-icon-arrowthick-1-n"/>
                <p:separator/>
                <p:menuitem value="Logout" action="#{LoginBean.logout()}" icon="ui-icon-power"/>
            </p:menuButton>
        </h:form>
        <h:form enctype="multipart/form-data">
            <p:dialog  modal="true" widgetVar="importDialog" header="Import new events" draggable="false" closable="true" resizable="false">
                    <p:growl id="growl" showDetail="true" />
                    <p:fileUpload value="#{scheduleBean.fileUploaded}" mode="simple"/>
                    <p:commandButton ajax="false" actionListener="#{scheduleBean.upload()}" value="Upload" onclick="PrimeFaces.monitorDownload(start, stop);"/>  
            </p:dialog>
        </h:form>
        <h:form>
            <p:dialog  modal="true" widgetVar="statusDialog" header="Loading" draggable="false" closable="false" resizable="false">
                <p:row><h:graphicImage library="images" name="progress.BAK-FOURTH.gif" /></p:row>
                <p:row>Please, wait...</p:row>
            </p:dialog>

<script type="text/javascript">
    function start() {
        PF('statusDialog').show();
    }

    function stop() {
        PF('statusDialog').hide();
    }

</script>
        
        
        <h:panelGrid id="panelSchedule" columnClasses="value" style="float: left; margin-top: 70px;margin-left: 70px; width: 850px">
            <p:schedule rendered="true" aspectRatio="2" id="schedulep" value="#{scheduleUserBean.addEventToEventModel()}"  resizable="false" draggable="false">
            <p:ajax event="eventSelect" listener="#{scheduleUserBean.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            </p:schedule>
        </h:panelGrid> 
        <p:dialog widgetVar="eventDialog" header="Event details" showEffect="clip" hideEffect="clip" resizable="false" draggable="false">
                <h:panelGrid id="eventDetails" columns="2">
                    <h:outputLabel for="name" value="Name:" />
                    <h:outputText id="name" value="#{scheduleUserBean.event.title}"/>
                    
                    <h:outputLabel for="description" value="Description:" />
                    <h:outputText id="description" value="#{scheduleUserBean.event.data}"/>

                    <h:outputLabel for="startDate" value="Start Date:" />
                    <h:outputText id="startDate" value="#{scheduleUserBean.event.startDate.getDate()}/#{scheduleUserBean.event.startDate.getMonth()+1}/#{scheduleUserBean.event.startDate.getYear()+1900}  #{scheduleUserBean.event.startDate.getHours()}h #{scheduleUserBean.event.startDate.getMinutes()}m"/>

                    <h:outputLabel for="endDate" value="End Date:" />
                    <h:outputText id="endDate" value="#{scheduleUserBean.event.endDate.getDate()}/#{scheduleUserBean.event.endDate.getMonth()+1}/#{scheduleUserBean.event.endDate.getYear()+1900}  #{scheduleUserBean.event.endDate.getHours()}h #{scheduleUserBean.event.endDate.getMinutes()}m"/>
                    
                    <p:commandButton action="#{scheduleUserBean.gotoPage()}" value="Event page"/>
                </h:panelGrid>
        </p:dialog>
        <p:fieldset legend="User" style="float: left; margin-top: 70px; margin-left: 100px; width: 220px">
        <h:panelGrid id="PanelProfile">
           <p:outputPanel>
                <h:panelGrid columns="2" cellpadding="5">
                    <h:outputText value="Name:" style="font-weight: bold"/>
                    <h:outputText value="#{scheduleUserBean.user.name}" />
 
                    <h:outputText value="Surname:" style="font-weight: bold"/>
                    <h:outputText value="#{scheduleUserBean.user.surname}" />
 
                    <h:outputText value="Email:" style="font-weight: bold"/>
                    <h:outputText value="#{scheduleUserBean.user.email}" />
                    
                    <h:outputText value="Gender:" style="font-weight: bold"/>
                    <h:outputText value="#{scheduleUserBean.user.gender}" />
                    
                    <h:outputText value="Date of birth:" style="font-weight: bold"/>
                    <h:outputText value="#{scheduleUserBean.user.dateOfBirth.getDate()}/#{scheduleUserBean.user.dateOfBirth.getMonth()+1}/#{scheduleUserBean.user.dateOfBirth.getYear()+1900}" />
                    
                    <h:outputText value="Schedule #{scheduleUserBean.user.idSchedule.public1? 'PUBLIC' : 'PRIVATE'}" style="font-weight: bold"/>
                </h:panelGrid>
            </p:outputPanel>
        </h:panelGrid>
        </p:fieldset>    
        </h:form>
            
    </h:body>
</html>

